package com.baseDemo.web.controller;

import java.util.List;
import java.util.Set;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baseDemo.web.entity.AuthorityEntity;
import com.baseDemo.web.service.authority.AuthorityService;

@Controller
@RequestMapping(value="/authority", produces = "application/json;charset=UTF-8")
public class AuthorityController {
	@Resource AuthorityService authorityService;
	
	@RequestMapping(value = "/getAuthorityByNavigation")
	@ResponseBody
	public List<AuthorityEntity> getAuthorityByNavigation(@RequestParam String navigationid){
		return authorityService.getAuthorityByNavigation(navigationid);
	}
	
	@RequestMapping(value = "/addAuthority")
	@ResponseBody
	public String addAuthority(@RequestBody AuthorityEntity authorityEntity){
		return "{'id':'" + authorityService.save(authorityEntity) + "'}";
	}
	
	@RequestMapping(value = "/destroyAuthority")
	@ResponseBody
	public String destroyAuthority(@RequestBody Set<AuthorityEntity> authorities){
		return authorityService.destroyAuthority(authorities);
	}
	@RequestMapping(value = "/updateAuthority")
	@ResponseBody
	public String updateAuthority(@RequestBody AuthorityEntity AuthorityEntity) {
		return authorityService.updateAuthority(AuthorityEntity);
	}
}
